import 'package:flutter/gestures.dart';
import '../widgets/url_switch/base_url_switch.dart';
import 'package:flutter/material.dart';

typedef OpenStatueCallback = void Function(bool isOpen);

class DebugPanelPage extends StatefulWidget {
  final OpenStatueCallback callback;

  DebugPanelPage({Key key, this.callback}) : super(key : key);

  @override
  _DebugPanelPageState createState() => _DebugPanelPageState();
}

class _DebugPanelPageState extends State<DebugPanelPage> {
  @override
  void initState() {
    super.initState();
    ///页面已经打开
    widget.callback?.call(true);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.blue,
        leading: IconButton(
          icon: Icon(Icons.arrow_back_ios),
          onPressed: () {
            Navigator.of(context).pop();
          },
        ),
        title: Text(
          "Debug面板",
          style: TextStyle(color: Color(0xffffffff), fontSize: 20),
        ),
        centerTitle: true,
      ),
      body: SingleChildScrollView(
          scrollDirection: Axis.vertical,
          dragStartBehavior: DragStartBehavior.start,
          physics: BouncingScrollPhysics(),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              BaseUrlSwitch()
            ],
          )),
    );
  }

  @override
  void dispose() {
    widget.callback?.call(false);
    super.dispose();
  }
}
